package com.vdong.interactive.course.common.security;


import com.vdong.interactive.course.common.enums.ApiContract;
import org.lamb.framework.core.config.LambSpringSecurityConfig;
import org.lamb.framework.core.security.AuthTokenReactiveAuthorizationManager;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.web.server.SecurityWebFilterChain;

import javax.annotation.Resource;


/**
 * @program: decisionsupportsystem
 * @description: spring权限框架配置
 * @author: Mr.WangGang
 * @create: 2018-08-29 17:08
 **/
@Configuration
public class SpringSecurityConfig extends LambSpringSecurityConfig {


    @Resource
    private AuthTokenReactiveAuthorizationManager authTokenReactiveAuthorizationManager;


    @Override
    public void strategy(ServerHttpSecurity http) {
        /*http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getAppPeddleGoodsList).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getAppPeddleGoodsCategoryList).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getAppIndexPeddleGoodsList).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getAppPeddleGoodsDetail).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getSubContext).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getGoodsSub).permitAll();
//      http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.indexGoodsChoice).permitAll();
//      http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.rotationGoodsChoice).permitAll();
        /*http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getPeddleGoodsList).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getStorePeddleGoodsList).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.addPeddleGoods).permitAll();
        http.authorizeExchange().pathMatchers("/goods/course" + ApiContract.getGoodsChoice).permitAll();
        http.authorizeExchange().pathMatchers("/goods/course" + ApiContract.getCourseDetail).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getStroePeddleGoodsDetail).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getPeddleGoodsDetail).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getStorePeddleGoodsCategoryList).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getPeddleGoodsCategoryList).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getAppPeddleGoodsList).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getAppPeddleGoodsCategoryList).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getAppIndexPeddleGoodsList).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getAppPeddleGoodsDetail).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getSubContext).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getGoodsSub).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.indexGoodsChoice).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.rotationGoodsChoice).permitAll();
        http.authorizeExchange().pathMatchers("/goods/peddleGoods" + ApiContract.getSubDetail).permitAll();*/
        //其余被ACCESS拦截
        http.authorizeExchange().anyExchange().access(authTokenReactiveAuthorizationManager);
    }
}